package de.fhb.itunes.manager;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;


public class Config {
	private Properties prop;
	
	
	private void readConfig(){
		prop = new Properties();
    	try {
            //load a properties file
    		//InputStream in = getClass().getResourceAsStream("/config.properties");
//    		prop.load(in);
//    		prop.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("config.properties"));
//    		prop.load(new FileInputStream("config.properties"));
    		
    		InputStream inputStream = this.getClass().getClassLoader()  
                    .getResourceAsStream("config.properties");  
    		prop.load(inputStream);
    	} catch (IOException ex) {
    		ex.printStackTrace();
        } 
	}
	public Properties getProperties(){
		readConfig();
		return this.prop;
	}
	public void saveConfig () {
		try {
			prop.store(new FileOutputStream("config.properties"), null);
		} catch (FileNotFoundException e) {
			
			e.printStackTrace();
		} catch (IOException e) {
			
			e.printStackTrace();
		}
	}
}
